﻿using System;
using System.Collections.Generic;
using System.Data.Linq.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TracNghiemV1.Database;

namespace TracNghiemV1.DAO
{
    class QuestionItemInfoDao
    {
        private static TestDataDataContext m_dataContext = null;

        public static void AddQuestionItemInfo(QUESTION_ITEM_INFO newQuestionItemInfo)
        {

            m_dataContext = DataContextDao.GetInstance();

            m_dataContext.QUESTION_ITEM_INFOs.InsertOnSubmit(newQuestionItemInfo);
            m_dataContext.SubmitChanges();
        }

        public static void DeleteQuestionItemInfo(int itemInfoId)
        {
            m_dataContext = DataContextDao.GetInstance();

            var qii = m_dataContext.QUESTION_ITEM_INFOs.Single(u => u.ITEM_INFO_ID == itemInfoId);
            m_dataContext.QUESTION_ITEM_INFOs.DeleteOnSubmit(qii);
            m_dataContext.SubmitChanges();
        }

        public static void ModifyQuestionItemInfo(QUESTION_ITEM_INFO qit)
        {
            m_dataContext = DataContextDao.GetInstance();

            var course = m_dataContext.QUESTION_ITEM_INFOs.Single(u => u.ITEM_INFO_ID == qit.ITEM_INFO_ID);

            course.ITEM_INFO_VALUE = qit.ITEM_INFO_VALUE;
          

            m_dataContext.SubmitChanges();
        }
        
    }
}
